#! -*- coding:utf-8 -*-
from numpy import *
import numpy as np
from sklearn import svm
from sklearn import datasets
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.feature_extraction.text import TfidfTransformer

data=['Shipment of gold damaged in a fire Delivery', 'Delivery of silver arrived in a silver t']
count_vect = CountVectorizer(stop_words="english",decode_error='ignore')
transformer=TfidfTransformer(smooth_idf=True)
X_train_counts = count_vect.fit_transform(data)
tfidf = transformer.fit_transform(X_train_counts)
weight=tfidf.toarray()
print weight
print count_vect.vocabulary_
print count_vect.stop_words_
print count_vect.get_feature_names()[1]
print X_train_counts.shape
print X_train_counts.toarray()
print 'sum',sum(X_train_counts.toarray())
#print map(float,sum(X_train_counts.toarray()))/X_train_counts.shape[0]
mata = mat(X_train_counts.toarray())
print multiply(mata,1.0/(X_train_counts.shape[0]))
print mata.sum(axis=0)
print np.mean(mata,axis=0)


